package com.keon.jianbao;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

import com.keon.jianbao.ui.activity.GuideActivity;
import com.keon.jianbao.ui.activity.MainActivity;
import com.keon.jianbao.util.StringUtils;

/**
 * Created by keon on 2015/7/13.
 */
public class AppStart extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final View view = View.inflate(this, R.layout.activity_start, null);
        setContentView(view);
        // 渐变展示启动屏
        AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f);
        aa.setDuration(800);
        view.startAnimation(aa);
        aa.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation arg0) {

                if (!StringUtils.isEmpty(AppContext.getInstance().getProperty("launch"))) {
                    Intent intent = new Intent();
                    intent.setClass(AppStart.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    AppContext.getInstance().setProperty("launch", "1");

                    Intent intent = new Intent();
                    intent.setClass(AppStart.this, GuideActivity.class);
                    startActivity(intent);
                    finish();
                }


                //设置切换动画，从右边进入，左边退出,带动态效果
//                overridePendingTransition(R.anim.dync_in_from_right, R.anim.dync_out_to_left);

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }
        });


    }
}
